<?php
class Exts_Security_SecureUser extends Exts_Security_SecureData  {
	protected $_userAdapter = "Exts_Security_ExtUserAdapter";
	protected $_userAdapterInstance = NULL;
	
	
	public function __construct ($username ="", $password=""){
		return Exts_Security_SecureData::__construct(array("username" => $username, "password" => $password));
	}

	public static function Load ($data){
		$sd = new Exts_Security_SecureUser();
		$sd->loadSecureData($data);
		return $sd;
	}

	public static function CreateFromTrueUser($user){
		return new Exts_Security_SecureUser ($user->username, $user->password);
	}

	protected function _getUserAdapterInstance() {
		if (!$this->_userAdapterInstance) {
			$class = $this->_userAdapter;
			$this->_userAdapterInstance = new $class();
		}
		return $this->_userAdapterInstance;
	}

	public function validateUser () {
		return $this->_getUserAdapterInstance()->validateUser($this);
	}

	public function getUser () {
		return $this->_getUserAdapterInstance()->getUser($this);
	}

	public function makeCertificate () {
		return new Exts_Security_Certificate ($this->getUser());
	}
}
